package net.lastcoder.ifserver.tool;

import net.lastcoder.ifserver.util.FileUtil;

import org.junit.Test;

import java.io.File;
import java.io.UnsupportedEncodingException;
import java.nio.charset.Charset;

/**
 * auth: WenYF
 * date: 2017/11/1
 */
public class FileEliminateNumber {

    public void eliminate(File file) throws UnsupportedEncodingException {
        byte[] data = FileUtil.readFileData(file.getAbsolutePath());
        String str = new String(data, Charset.forName("GB2312"));
        str = str.replaceAll("\\d+|/|\t| ", "");
        data = str.getBytes("GB2312");
        FileUtil.writeData2File(data, file);
    }

    @Test
    public void goEliminate() throws UnsupportedEncodingException {
        File dir = new File("C:\\Users\\Administrator\\Desktop\\MonItems");
        File[] files = dir.listFiles();
        for (File file : files) {
            eliminate(file);
        }
    }

}
